import React from 'react'
import styles from './index.less'
import { Row, Col, Button,Form, Input, Icon,Select } from 'antd'
import {format} from '../../utils'
const Option = Select.Option;
const FormItem = Form.Item;
const formItemLayout = {
  labelCol: {
    span: 24,
		
  },
  wrapperCol: {
    xs:12,
    sm:16,
    md:12,
    lg:8,
    xl:5
  },
}

class add extends React.Component {
    mobileNumber =(rule, value, callback)=>{
        console.log("value==",value!= '')
        const form = this.props.form;
        const num = /^(([1-9][0-9]*\.[0-9][0-9]*)|([0]\.[0-9][0-9]*)|([1-9][0-9]*)|([0]{1}))$/
        if(value != ''){
            if(!num.test(value)){
                callback('请输入正确的运输单价!');
            }else{
                callback();
            }
        }else{
            callback();
        }
    }
    render() {
        const {onOk,detail,autStatus} = this.props
        const { getFieldDecorator } = this.props.form;
        const handleSubmit = (e) => {
            e.preventDefault();
            this.props.form.validateFields((err, values) => {
                if (!err) {
                    const data = {
                        id:detail.id,
                        status:1,
                        payWay:values.payWay,
                        payType:values.payType,
                        unitPrice:values.unitPrice,
                    }
                    onOk(data)
                }
            });
        }
    return (
      <div>
        <div className={styles.filterTop}>
            <div className={styles.title}><span style={{marginRight:20}}>{detail.trueName}</span>
                <Button type="primary" onClick={handleSubmit}>确认审核</Button>
            </div>
            <div className={styles.Searchright}>
            </div>
        </div>
        <div className={styles.listbox}>
            <Form onSubmit={handleSubmit} className="login-form" >
                <FormItem {...formItemLayout} label="结算方式">
                {getFieldDecorator('payWay', {
                    rules: [{ required: true, message: '选择结算方式' }],
                })(
                    <Select >
                        <Option value="3">现结</Option>
                        <Option value="2">日结</Option>
                        <Option value="1">月结</Option>
                    </Select>
                )}
                </FormItem>
                <FormItem {...formItemLayout} label="支付类型">
                {getFieldDecorator('payType', {
                    rules: [{ required: true, message: '选择支付类型' }],
                })(
                    <Select >
                        <Option value="1">趟</Option>
                        <Option value="4">件</Option>
                        <Option value="2">重量</Option>
                        <Option value="3">体积</Option>
                    </Select>
                )}
                </FormItem>
                <FormItem {...formItemLayout} label="运输单价(元)">
                {getFieldDecorator('unitPrice', {
                    rules: [
                        { required: true,message:'请输入运输单价'},
                        { validator: this.mobileNumber}
                    ],
                    
                })(
                    <Input placeholder="订单的运输单价" />
                )}
                </FormItem>
            </Form>
        </div>
      </div>
    );
  }
}
export default Form.create()(add)
